(function() {
	var t = (function() {
		var x = {};
		var y = [];
		x.inc = function(A, z) {
			return true
		};
		x.register = function(B, z) {
			var D = B.split(".");
			var C = x;
			var A = null;
			while (A = D.shift()) {
				if (D.length) {
					if (C[A] === undefined) {
						C[A] = {}
					}
					C = C[A]
				} else {
					if (C[A] === undefined) {
						try {
							C[A] = z(x)
						} catch (E) {
						}
					}
				}
			}
		};
		x.regShort = function(z, A) {
			if (x[z] !== undefined) {
				throw "[" + z + "] : short : has been register"
			}
			x[z] = A
		};
		x.IE = /msie/i.test(navigator.userAgent);
		x.E = function(z) {
			if (typeof z === "string") {
				return document.getElementById(z)
			} else {
				return z
			}
		};
		x.C = function(z) {
			var A;
			z = z.toUpperCase();
			if (z == "TEXT") {
				A = document.createTextNode("")
			} else {
				if (z == "BUFFER") {
					A = document.createDocumentFragment()
				} else {
					A = document.createElement(z)
				}
			}
			return A
		};
		x.log = function(z) {
			y.push("[" + ((new Date()).getTime() % 100000) + "]: " + z)
		};
		x.getErrorLogInformationList = function(z) {
			return y.splice(0, z || y.length)
		};
		return x
	})();
	$Import = t.inc;
	t.register("core.evt.addEvent", function(x) {
		return function(y, B, A) {
			var z = x.E(y);
			if (z == null) {
				return false
			}
			B = B || "click";
			if ((typeof A).toLowerCase() != "function") {
				return
			}
			if (z.attachEvent) {
				z.attachEvent("on" + B, A)
			} else {
				if (z.addEventListener) {
					z.addEventListener(B, A, false)
				} else {
					z["on" + B] = A
				}
			}
			return true
		}
	});
	t.register("core.obj.parseParam", function(x) {
		return function(A, z, y) {
			var B, C = {};
			z = z || {};
			for (B in A) {
				C[B] = A[B];
				if (z[B] != null) {
					if (y) {
						if (A.hasOwnProperty[B]) {
							C[B] = z[B]
						}
					} else {
						C[B] = z[B]
					}
				}
			}
			return C
		}
	});
	t.register("core.json.strToJson", function(D) {
		var A, y, x = {
			'"' : '"',
			"\\" : "\\",
			"/" : "/",
			b : "\b",
			f : "\f",
			n : "\n",
			r : "\r",
			t : "\t"
		}, K, I = function(L) {
			throw new Error("SyntaxError: " + L + "," + A + "," + K)
		}, E = function(L) {
			if (L && L !== y) {
				I("Expected '" + L + "' instead of '" + y + "'")
			}
			y = K.charAt(A);
			A += 1;
			return y
		}, C = function() {
			var M, L = "";
			if (y === "-") {
				L = "-";
				E("-")
			}
			while (y >= "0" && y <= "9") {
				L += y;
				E()
			}
			if (y === ".") {
				L += ".";
				while (E() && y >= "0" && y <= "9") {
					L += y
				}
			}
			if (y === "e" || y === "E") {
				L += y;
				E();
				if (y === "-" || y === "+") {
					L += y;
					E()
				}
				while (y >= "0" && y <= "9") {
					L += y;
					E()
				}
			}
			M = +L;
			if (isNaN(M)) {
				I("Bad number")
			} else {
				return M
			}
		}, F = function() {
			var O, N, M = "", L;
			if (y === '"') {
				while (E()) {
					if (y === '"') {
						E();
						return M
					} else {
						if (y === "\\") {
							E();
							if (y === "u") {
								L = 0;
								for (N = 0; N < 4; N += 1) {
									O = parseInt(E(), 16);
									if (!isFinite(O)) {
										break
									}
									L = L * 16 + O
								}
								M += String.fromCharCode(L)
							} else {
								if (typeof x[y] === "string") {
									M += x[y]
								} else {
									break
								}
							}
						} else {
							M += y
						}
					}
				}
			}
			I("Bad string")
		}, H = function() {
			while (y && y <= " ") {
				E()
			}
		}, z = function() {
			switch (y) {
			case "t":
				E("t");
				E("r");
				E("u");
				E("e");
				return true;
			case "f":
				E("f");
				E("a");
				E("l");
				E("s");
				E("e");
				return false;
			case "n":
				E("n");
				E("u");
				E("l");
				E("l");
				return null
			}
			I("Unexpected '" + y + "'")
		}, J, G = function() {
			var L = [];
			if (y === "[") {
				E("[");
				H();
				if (y === "]") {
					E("]");
					return L
				}
				while (y) {
					L.push(J());
					H();
					if (y === "]") {
						E("]");
						return L
					}
					E(",");
					H()
				}
			}
			I("Bad array")
		}, B = function() {
			var M, L = {};
			if (y === "{") {
				E("{");
				H();
				if (y === "}") {
					E("}");
					return L
				}
				while (y) {
					M = F();
					H();
					E(":");
					if (Object.hasOwnProperty.call(L, M)) {
						I('Duplicate key "' + M + '"')
					}
					L[M] = J();
					H();
					if (y === "}") {
						E("}");
						return L
					}
					E(",");
					H()
				}
			}
			I("Bad object")
		};
		J = function() {
			H();
			switch (y) {
			case "{":
				return B();
			case "[":
				return G();
			case '"':
				return F();
			case "-":
				return C();
			default:
				return y >= "0" && y <= "9" ? C() : z()
			}
		};
		return function(O, M) {
			var L;
			K = O;
			A = 0;
			y = " ";
			L = J();
			H();
			if (y) {
				I("Syntax error")
			}
			return typeof M === "function" ? (function N(S, R) {
				var Q, P, T = S[R];
				if (T && typeof T === "object") {
					for (Q in T) {
						if (Object.hasOwnProperty.call(T, Q)) {
							P = N(T, Q);
							if (P !== undefined) {
								T[Q] = P
							} else {
								delete T[Q]
							}
						}
					}
				}
				return M.call(S, R, T)
			}({
				"" : L
			}, "")) : L
		}
	});
	t
			.register(
					"core.json.jsonToStr",
					function(A) {
						function B(H) {
							return H < 10 ? "0" + H : H
						}
						if (typeof Date.prototype.toJSON !== "function") {
							Date.prototype.toJSON = function(H) {
								return isFinite(this.valueOf()) ? this
										.getUTCFullYear()
										+ "-"
										+ B(this.getUTCMonth() + 1)
										+ "-"
										+ B(this.getUTCDate())
										+ "T"
										+ B(this.getUTCHours())
										+ ":"
										+ B(this.getUTCMinutes())
										+ ":"
										+ B(this.getUTCSeconds()) + "Z" : null
							};
							String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function(
									H) {
								return this.valueOf()
							}
						}
						var z = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, D = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, E, y, G = {
							"\b" : "\\b",
							"\t" : "\\t",
							"\n" : "\\n",
							"\f" : "\\f",
							"\r" : "\\r",
							'"' : '\\"',
							"\\" : "\\\\"
						}, F;
						function x(H) {
							D.lastIndex = 0;
							return D.test(H) ? '"'
									+ H.replace(D, function(I) {
										var J = G[I];
										return typeof J === "string" ? J
												: "\\u"
														+ ("0000" + I
																.charCodeAt(0)
																.toString(16))
																.slice(-4)
									}) + '"' : '"' + H + '"'
						}
						function C(O, L) {
							var J, I, P, H, M = E, K, N = L[O];
							if (N && typeof N === "object"
									&& typeof N.toJSON === "function") {
								N = N.toJSON(O)
							}
							if (typeof F === "function") {
								N = F.call(L, O, N)
							}
							switch (typeof N) {
							case "string":
								return x(N);
							case "number":
								return isFinite(N) ? String(N) : "null";
							case "boolean":
							case "null":
								return String(N);
							case "object":
								if (!N) {
									return "null"
								}
								E += y;
								K = [];
								if (Object.prototype.toString.apply(N) === "[object Array]") {
									H = N.length;
									for (J = 0; J < H; J += 1) {
										K[J] = C(J, N) || "null"
									}
									P = K.length === 0 ? "[]" : E ? "[\n" + E
											+ K.join(",\n" + E) + "\n" + M
											+ "]" : "[" + K.join(",") + "]";
									E = M;
									return P
								}
								if (F && typeof F === "object") {
									H = F.length;
									for (J = 0; J < H; J += 1) {
										I = F[J];
										if (typeof I === "string") {
											P = C(I, N);
											if (P) {
												K.push(x(I) + (E ? ": " : ":")
														+ P)
											}
										}
									}
								} else {
									for (I in N) {
										if (Object.hasOwnProperty.call(N, I)) {
											P = C(I, N);
											if (P) {
												K.push(x(I) + (E ? ": " : ":")
														+ P)
											}
										}
									}
								}
								P = K.length === 0 ? "{}" : E ? "{\n" + E
										+ K.join(",\n" + E) + "\n" + M + "}"
										: "{" + K.join(",") + "}";
								E = M;
								return P
							}
						}
						return function(K, I, J) {
							var H;
							E = "";
							y = "";
							if (typeof J === "number") {
								for (H = 0; H < J; H += 1) {
									y += " "
								}
							} else {
								if (typeof J === "string") {
									y = J
								}
							}
							F = I;
							if (I
									&& typeof I !== "function"
									&& (typeof I !== "object" || typeof I.length !== "number")) {
								throw new Error("JSON.stringify")
							}
							return C("", {
								"" : K
							})
						}
					});
	t.register("core.arr.isArray", function(x) {
		return function(y) {
			return Object.prototype.toString.call(y) === "[object Array]"
		}
	});
	t.register("core.str.trim", function(x) {
		return function(B) {
			if (typeof B !== "string") {
				throw "trim need a string as parameter"
			}
			var y = B.length;
			var A = 0;
			var z = /(\u3000|\s|\t|\u00A0)/;
			while (A < y) {
				if (!z.test(B.charAt(A))) {
					break
				}
				A += 1
			}
			while (y > A) {
				if (!z.test(B.charAt(y - 1))) {
					break
				}
				y -= 1
			}
			return B.slice(A, y)
		}
	});
	t.register("core.json.queryToJson", function(x) {
		return function(A, E) {
			var G = x.core.str.trim(A).split("&");
			var F = {};
			var z = function(I) {
				if (E) {
					return decodeURIComponent(I)
				} else {
					return I
				}
			};
			for ( var C = 0, D = G.length; C < D; C++) {
				if (G[C]) {
					var B = G[C].split("=");
					var y = B[0];
					var H = B[1];
					if (B.length < 2) {
						H = y;
						y = "$nullName"
					}
					if (!F[y]) {
						F[y] = z(H)
					} else {
						if (x.core.arr.isArray(F[y]) != true) {
							F[y] = [ F[y] ]
						}
						F[y].push(z(H))
					}
				}
			}
			return F
		}
	});
	t
			.register(
					"core.util.browser",
					function(D) {
						var x = navigator.userAgent.toLowerCase();
						var G = window.external || "";
						var z, A, B, H, C;
						var y = function(I) {
							var J = 0;
							return parseFloat(I.replace(/\./g, function() {
								return (J++ == 1) ? "" : "."
							}))
						};
						try {
							if ((/windows|win32/i).test(x)) {
								C = "windows"
							} else {
								if ((/macintosh/i).test(x)) {
									C = "macintosh"
								} else {
									if ((/rhino/i).test(x)) {
										C = "rhino"
									}
								}
							}
							if ((A = x.match(/applewebkit\/([^\s]*)/)) && A[1]) {
								z = "webkit";
								H = y(A[1])
							} else {
								if ((A = x.match(/presto\/([\d.]*)/)) && A[1]) {
									z = "presto";
									H = y(A[1])
								} else {
									if (A = x.match(/msie\s([^;]*)/)) {
										z = "trident";
										H = 1;
										if ((A = x.match(/trident\/([\d.]*)/))
												&& A[1]) {
											H = y(A[1])
										}
									} else {
										if (/gecko/.test(x)) {
											z = "gecko";
											H = 1;
											if ((A = x.match(/rv:([\d.]*)/))
													&& A[1]) {
												H = y(A[1])
											}
										}
									}
								}
							}
							if (/world/.test(x)) {
								B = "world"
							} else {
								if (/360se/.test(x)) {
									B = "360"
								} else {
									if ((/maxthon/.test(x))
											|| typeof G.max_version == "number") {
										B = "maxthon"
									} else {
										if (/tencenttraveler\s([\d.]*)/.test(x)) {
											B = "tt"
										} else {
											if (/se\s([\d.]*)/.test(x)) {
												B = "sogou"
											}
										}
									}
								}
							}
						} catch (F) {
						}
						var E = {
							OS : C,
							CORE : z,
							Version : H,
							EXTRA : (B ? B : false),
							IE : /msie/.test(x),
							OPERA : /opera/.test(x),
							MOZ : /gecko/.test(x)
									&& !/(compatible|webkit)/.test(x),
							IE5 : /msie 5 /.test(x),
							IE55 : /msie 5.5/.test(x),
							IE6 : /msie 6/.test(x),
							IE7 : /msie 7/.test(x),
							IE8 : /msie 8/.test(x),
							IE9 : /msie 9/.test(x),
							SAFARI : !/chrome\/([\d.]*)/.test(x)
									&& /\/([\d.]*) safari/.test(x),
							CHROME : /chrome\/([\d.]*)/.test(x),
							IPAD : /\(ipad/i.test(x),
							IPHONE : /\(iphone/i.test(x),
							ITOUCH : /\(itouch/i.test(x),
							MOBILE : /mobile/i.test(x)
						};
						return E
					});
	t.register("core.util.getUniqueKey", function(z) {
		var x = (new Date()).getTime().toString(), y = 1;
		return function() {
			return x + (y++)
		}
	});
	var r = "https://api.weibo.com";
	var b;
	var h = document.URL.replace(/([^:]+:\/\/[^\/]+).*/, "$1");
	var c = 0;
	var p = [];
	var q = 0;
	var o = parent.WB2.Cookie.load().access_token || "";
	var k = parent.WB2._config.appkey;
	var e = r + "/oauth2/xd.jsp?appkey=" + k + "&access_token=" + o
			+ "&referer=" + encodeURIComponent(parent.document.location.href);
	var s = parent.WB2._config.host;
	var w = parent.WB2._config.cssHost;
	var i = parent.WB2.Module;
	var n = k ? true : false;
	window.WB2 = window.WB2 || {};
	var g = function(x, A) {
		var y;
		y = parent.document.createElement("script");
		y.charset = "UTF-8";
		var z = /msie/i.test(navigator.userAgent);
		if (z) {
			y.onreadystatechange = function() {
				if (y.readyState.toLowerCase() == "complete"
						|| y.readyState.toLowerCase() == "loaded") {
					A();
					y.onreadystatechange = null
				}
			}
		} else {
			y.onload = function() {
				A();
				y.onload = null
			}
		}
		y.src = x;
		parent.document.getElementsByTagName("head")[0].appendChild(y);
		return y
	};
	WB2.getTrans = function(z) {
		var B = t.core.obj.parseParam({
			id : "STK_iframe_" + t.core.util.getUniqueKey(),
			callback : function() {
			}
		}, z);
		var D = this;
		var A = function(F) {
			try {
				D._iframe = document.createElement('<iframe name="' + F + '">')
			} catch (E) {
				D._iframe = document.createElement("iframe")
			}
			D._iframe.id = F;
			D._iframe.name = F;
			D._iframe.src = "";
			document.body.insertBefore(D._iframe, document.body.firstChild)
		};
		A(B.id);
		var x = "cbk_" + c;
		var y = p[x] = {};
		y.callback = B.callback;
		c++;
		l._messagePoll(window, "name");
		var C = {};
		C.getId = function() {
			return B.id
		};
		C.getIndex = function() {
			return x
		};
		C.destroy = function() {
			D._iframe && D._iframe.parentNode
					&& D._iframe.parentNode.removeChild(D._iframe)
		};
		return C
	};
	var v = function() {
		this.started = 1;
		this.taskList = [];
		this.setStatue = function(x) {
			this.started = x
		};
		this.start = function() {
			this.setStatue(0);
			var z, B, y, A;
			var x = this.taskList.shift();
			B = x[0];
			y = x[1];
			A = x[2];
			B.apply(A, y)
		};
		this.next = function() {
			this.setStatue(1);
			if (this.taskList.length > 0) {
				this.start()
			}
		};
		this.add = function(z, y) {
			var x = {
				args : [],
				pointer : window,
				top : false
			};
			x = t.core.obj.parseParam(x, y);
			if (x.top) {
				this.taskList.unshift([ z, x.args, x.pointer ])
			} else {
				this.taskList.push([ z, x.args, x.pointer ])
			}
			if (this.started) {
				this.start()
			}
		}
	};
	var m = new v();
	var u = {
		baseUrl : s + "/open/api",
		baseCssUrl : w,
		widgetCache : {},
		loadCss : function(x) {
			css = parent.document.createElement("link");
			css.href = x;
			css.type = "text/css";
			css.rel = "stylesheet";
			parent.document.getElementsByTagName("head")[0].appendChild(css);
			u.widgetCache[x] = 1
		},
		getWidgetFile : function(B, x) {
			var z = i[B];
			if (!z) {
				throw ("Module " + B + " can not be found!")
			}
			z = i[B]["versions"][x];
			if (!z) {
				z = i[B]["versions"]["latest"]
			}
			var y = z.js.replace("{ver}", x);
			var C = (z.css != null ? z.css : i[B]["versions"]["latest"]["css"])
					|| "";
			var D = this.baseUrl + "/js/widget/" + B + "/" + y;
			var A = C != "" ? (/^http:\/\//.test(C) ? C : this.baseCssUrl + C)
					: "";
			return {
				js : D,
				css : A
			}
		},
		loadWidget : function(B, D) {
			var y = B.module, x = B.version, C = B.loadcss;
			var A = this.getWidgetFile(y, x);
			var z = function() {
				D && D();
				m.next()
			};
			m.add(this._init, {
				args : [ A.js, z ]
			});
			if (!C) {
				return
			}
			if (A.css && !this.widgetCache[A.css]) {
				this.loadCss(A.css)
			}
		},
		_init : function(x, y) {
			if (u.widgetCache[x]) {
				y && y()
			} else {
				g(x, function() {
					u.widgetCache[x] = 1;
					y && y()
				})
			}
		}
	};
	WB2.widget = (function() {
		var y = {
			load : function(D, B) {
				var z = D.module || "", E, C = true;
				if (z == "") {
					throw "no availiable module found."
				}
				if (typeof B === "string") {
					E = B || "latest"
				} else {
					if (typeof B === "object") {
						E = B.version || "latest";
						C = B.loadcss
					}
				}
				var A = {
					module : z,
					version : E,
					loadcss : C
				};
				if (z == "connectButton") {
					z = "loginButton"
				}
				u.loadWidget(A, function() {
					parent.WB2.widget[z].call(window, D.params)
				});
				return this
			}
		};
		for ( var x in i) {
			if (x && i[x]) {
				if (x == "loginButton") {
					y.connectButton = (function(z) {
						return function(A, B) {
							y.load({
								module : z,
								params : A
							}, B)
						}
					})(x)
				}
				y[x] = (function(z) {
					return function(A, B) {
						y.load({
							module : z,
							params : A
						}, B)
					}
				})(x)
			}
		}
		return y
	})();
	var a = new v();
	WB2.parseCMD = function(z, y, A, F) {
		var C = {
			method : "post",
			type : "json",
			cache_time : 0
		};
		C = t.core.obj.parseParam(C, F);
		var E = A || {};
		E.source = k;
		E._cache_time = C.cache_time;
		E.method = C.method;
		E._uri = z;
		E.origin = h;
		var B = parent.WB2.Cookie.load();
		E.access_token = B.access_token;
		var D = "cbk_" + c;
		var x = p[D] = {};
		x.callback = y;
		c++;
		E.cbk_index = D;
		if (window.postMessage) {
			l.sendMessage(E)
		} else {
			a.add(l.sendMessage, {
				args : [ E ]
			})
		}
	};
	parent.WB2.parseCMD = WB2.parseCMD;
	var d = "";
	var l = {
		setup : function(z, A) {
			var y = 1;
			var x = window.postMessage;
			if (x) {
				this.transport = "postMessage"
			} else {
				this.transport = "name"
			}
			l.createIframe = function(B) {
				if (!b) {
					b = t.C("iframe");
					b.id = "sina_weibo_xd_iframe";
					b.src = e;
					if (B) {
						t.core.evt.addEvent(b, "load", B)
					}
					document.body.insertBefore(b, document.body.firstChild)
				}
			};
			l.sendMessage = function(C) {
				var B = t.core.json.jsonToStr(C);
				var D = escape(B);
				switch (l.transport) {
				case "postMessage":
					b.contentWindow.postMessage(D, z);
					break;
				case "name":
					l._messagePoll(window, "name");
					b.contentWindow.name = (new Date()).getTime() + (y++) + "^"
							+ document.domain + "&" + window.escape(D);
					break
				}
			};
			l._messageHandler = function(F) {
				var G = unescape(F.data);
				var I, E, D, C;
				try {
					I = t.core.json.queryToJson(G);
					E = t.core.json.strToJson(unescape(I.data));
					D = I.status;
					C = I.cbkIndex || 0
				} catch (H) {
					D = false;
					C = I.cbkIndex || 0;
					E = {
						error : H.message
					}
				}
				var B = p[C];
				if (B && B.callback) {
					B.callback(E, (D == "true" || D == true))
				} else {
					if (I.requestType) {
						p[I.requestType] && p[I.requestType].call(this, E);
						delete p[I.requestType]
					}
				}
				a.next()
			};
			l._messagePoll = function(B, E) {
				function C(G) {
					var H = G.split("^").pop().split("&");
					return {
						domain : H[0],
						data : window.unescape(H[1])
					}
				}
				function D() {
					var G = B[E];
					if (G != d) {
						d = G;
						clearInterval(F);
						l._messageHandler(C(G))
					}
				}
				var F = setInterval(D, 1000 / 20)
			};
			if (x) {
				t.core.evt.addEvent(window, "message", l._messageHandler)
			}
			l.createIframe(A)
		}
	};
	window.request = function(x) {
		if (x.requestType === "anywhere") {
			x.callback(window.WB2)
		} else {
			x = x || {};
			x.callback = x.callback || function() {
			};
			p[x.requestType] = x.callback;
			l.sendMessage(x)
		}
	};
	function j() {
		var A = window._initCallbacks;
		var x = A.length;
		if (x > 0) {
			for ( var z = 0; z < x; z++) {
				var y = A[z];
				if (y.requestType === "anywhere") {
					y.callback(window.WB2)
				} else {
					window.request(y)
				}
			}
		}
	}
	var f = function() {
		window._ready = true;
		j()
	};
	if (n) {
		l.setup(r, function() {
			f()
		})
	} else {
		f()
	}
})();